<style lang="less" scoped>
    @import './login.less';
</style>
<template>
    <div class="wrapper">
        <div class="wrapper-container">
            <div class="wrapper-container-left">
                <p class="title">学值网</p>
                <p class="subhead">开源多功能系统</p>
            </div>
            <div class="wrapper-container-right">
                <h2>系统登录</h2>
                <div class="wrapper-form">
                    <login-form @on-success-valid="handleSubmit"></login-form>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    import LoginForm from '_c/login-form'
    import { mapActions } from 'vuex'
    export default {
        components: {
            LoginForm
        },
        methods: {
            ...mapActions([
                'handleLogin',
                'getAdminInfo'
            ]),
            handleSubmit ({ userName, password }) {
                this.handleLogin({ userName, password }).then(res => {
                    this.$Message.success(res.msg);
                    if(res.code === 0){
                        let that = this
                        setTimeout(function () {
                            that.getAdminInfo().then(res => {
                                that.$router.push({
                                    name: that.$config.homeName
                                })
                            })
                        },500)
                    }
                })
            }
        },
        mounted() {

        }
    }
</script>




